import { useState, useEffect } from 'react'
import { ipcRenderer } from 'electron'

export const useGetDebugData = (data?: File | null) => {
    const [debugList, setDebugList] = useState<DebugItem[]>([])

    useEffect(() => {
        if (data) {
            const transferData = {
                path: data.path,
                name: data.name
            }

            ipcRenderer.invoke('exec-app', JSON.stringify(transferData)).then((res: DebugItem[]) => {
                setDebugList(res)
            }).catch(err => {

            })
        }
    }, [data])


    return {
        debugList,
        setDebugList
    }
}